package cn.itsource.pethome.utils;

import cn.itsource.pethome.user.domain.User;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletRequest;

public class UserContext {

    public static User getUser(HttpServletRequest request){
        String token = request.getHeader("U-TOKEN");
        //从redis中获取到用户信息
        String userJSON = RedisUtils.INSTANCE.get(token);
        User user = JSONObject.parseObject(userJSON, User.class);
        return user;
    }
}
